package top.yihoxu.client;

import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import top.yihoxu.entity.Avatar;
import top.yihoxu.entity.User;

/**
 * @Author dth
 * @Date 2024/7/27 17:37
 * @PackageName:top.yihoxu.client
 * @ClassName: AvatarClient
 * @Description: TODO
 * @Version 1.0
 */
public class AvatarClient {
    public Avatar invoke(String requestParams, ApiClient apiClient) {
        int rightIndex = requestParams.indexOf("]");
        String params = requestParams.substring(1, rightIndex);
        HttpResponse response = HttpRequest.post("http://localhost:8123/api/avatar")
                .addHeaders(apiClient.getHeadMap(params))
                .body(params)
                .execute();
        String res = response.body();
        Avatar avatar = new Avatar();
        avatar.setAvatarUrl(res);
        return avatar;
    }
}
